﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EPS.Common
{
    public static class CustomExtendMethod
    {
        /// <summary>
        /// 实现对象的深拷贝,
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="objSource"></param>
        /// <returns></returns>
        public static TEntity DeepCopy<TEntity>(this TEntity objSource)
        {
            if (objSource != null)
            {
                MemorySerializer ms = new MemorySerializer();
                byte[] bytes = ms.ToSerializer(objSource);
                return ms.ToEntity<TEntity>(bytes);
            }
            else
                return objSource;
        }

        public static string CovertStrings(this string[] arry, string separator)
        {
            string result = string.Empty;
            if (arry != null && arry.Length > 0)
            {
                foreach (var item in arry)
                {
                    result = separator + item;
                }
                result = result.Remove(0, 1);
            }
            return result;
        }
    }
}
